package com.bjsxt.common.util;

import java.util.Random;

public class RandomUtil
{
	private String str="0123456789ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz";
	
	//生成指定长度的随机数
	public String getRandom(int len)
	{
		StringBuffer sb=new StringBuffer();
		Random random=new Random();
		for(int i=0;i<len;i++)
		{
			int randomOne = random.nextInt(str.length());
			sb.append(str.charAt(randomOne));
		}
		return sb.toString();
	}
	public static void main(String[] args)
	{
		String random = new RandomUtil().getRandom(4);
		
		System.out.println(random);
	}
}
